Skip to content

feat(parser-react): API-client wrapper adapter — heuristic detection + config, chains to depth 3#8

Merged
officialCodeWork merged 1 commit into
developmentfrom
build/phase-1/step-1.2-api-wrapper
Jul 13, 2026
Merged

feat(parser-react): API-client wrapper adapter — heuristic detection + config, chains to depth 3#8
officialCodeWork merged 1 commit into
developmentfrom
build/phase-1/step-1.2-api-wrapper

Conversation

@officialCodeWork

Copy link
Copy Markdown
Owner

Summary

TRACKER Step 1.2 — the wrapper half of C2. Real codebases never call fetch inline; they route through client layers. The scanner now sees through them:

useApi("/projects") → apiClient.get(path) → request(path) → fetch(`${API_BASE}${path}`)
                                     ⇒ ProjectsPage ← GET /api/projects

How it works

  • Heuristic detection — any named callable (function declaration, const arrow, object-literal method) whose body reaches fetch/axios/another wrapper with one of its own parameters inside the URL is classified as a wrapper. Runs up to 3 composition rounds, so three-layer chains resolve.
  • Template composition — each wrapper stores its endpoint shape with a :param marker (request/api:path); chains substitute inward, constants fold along the way. Call sites then substitute the real argument: apiClient.get("/projects")/api/projects (full).
  • Method inference — name suffix wins (apiClient.post → POST), inner call's method otherwise.
  • apiWrappers scan option — declare wrappers the heuristic can't see (imported clients, class-based SDKs).
  • No placeholder leakage — wrapper bodies emit no data sources of their own; the fixture's forbidden assertions gate the :path-leak poison forever.

Eval movement

  • New fixture c2-api-wrapper (the three-layer chain, GET via hook + POST via event handler).
  • Threshold ratcheted: minLineageRecall: 0.85.
  • Scorecard: 47 pass / 0 fail / 2 xfail / 0 unexpected-pass · precision 1.000 · recall 0.857 (was 0.833) · match accuracy 1.000.

Test plan

  • 39 unit tests green (6 new: function wrapper, prefix capture, object methods + suffix inference, 3-layer composition, config registration, non-wrapper rejection)
  • pnpm eval gate OK

Documentation

  • TRACKER.md — 1.2 done, Status → 1.3

🤖 Generated with Claude Code

…+ config, chains to depth 3

Step 1.2 (TRACKER). Failure mode C2 (wrapper half):

- detectWrappers: any named callable (function, const fn, object-literal
  method) whose body reaches fetch/axios/another wrapper with one of its own
  params in the URL is classified as a wrapper. Templates compose through
  chains (useApi → apiClient.get → request → fetch), so a call site's
  argument substitutes all the way down with constants folded:
  useApi('/projects') → /api/projects.
- Method inference: name suffix (apiClient.post → POST) beats inner method.
- ScanOptions.apiWrappers declares wrappers the heuristic can't see.
- Wrapper bodies are plumbing: their own internal fetch emits no data source,
  so ':path' placeholders never leak into consumer attribution (fixture has
  forbidden assertions for exactly that poison).
- Thresholds ratcheted: minLineageRecall 0.85. Scorecard: 47 pass / 0 fail /
  2 xfail; recall 0.857. 39 unit tests (6 new wrapper tests).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@officialCodeWork
officialCodeWork merged commit fb780e7 into development Jul 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants